<template>
  <div class="home">
    <banner :banner="banner" />
    <navs />
    <product :bar="bargaining" />
    <choiceness :news="news" />
    <goods :goods="bargaining" />
  </div>
</template>

<script>
import { getbanner, getKanjia,news,getgoods } from "@/utils/api/Index.js";
import banner from "@/components/Banner";
import navs from "@/components/Nav";
import product from "@/components/Product";
import choiceness from '@/components/Choiceness';
import goods from '@/components/Goods';

export default {
  data() {
    return {
      banner: [],
      // 轮播图数据
      bargaining: [],
      // 砍价数据
      news:[],
      // 精选专题
      goods:[],
      // 人气推荐数据
    };
  },
  mounted() {
    getbanner().then((res) => {
      this.banner = res.data;
    });
    // 获取轮播图数据
    getKanjia().then((res) => {
      for (let i in res.data.goodsMap) {
        this.bargaining.push(res.data.goodsMap[i]);
      }
    });
    // 砍价数据
  news().then(res=>{
    this.news = res.data;
    
  });
  // 精选专题数据
  getgoods().then(res=>{
    this.goods = res.data;
  })

  },
  components: {
    banner,
    navs,
    product,
    choiceness,
    goods
  },
};
</script>

<style lang="scss">
</style>